(function(window){
	function Jindu(jindu_bottom,jindu_tiao,jindu_dian){
		return new Jindu.prototype.init(jindu_bottom,jindu_tiao,jindu_dian)
	}
	Jindu.prototype={
		constructor:Jindu,
		init:function(jindu_bottom,jindu_tiao,jindu_dian){
			this.jindu_bottom=jindu_bottom;
			this.jindu_tiao=jindu_tiao;
			this.jindu_dian=jindu_dian;
		},
		move:0,
		jindu_click:function(callback){
			var this_Jindu=this
			this.jindu_bottom.click(function(event){
				var bottom_left=$(this).offset().left
				var click_left=event.pageX
				var jindu_ed=click_left-bottom_left
				this_Jindu.jindu_tiao.css("width",jindu_ed)
				this_Jindu.jindu_dian.css("left",jindu_ed)
				var rate=jindu_ed/this_Jindu.jindu_bottom.width()
				callback(rate)
			})
		},
		jindu_drag:function(mode,callback){
			var this_Jindu=this
			this.jindu_bottom.mousedown(function(){
				//this_Jindu.move=1		//?
				$(document).mousemove(function(event){		//bug
					this_Jindu.move=1
					var bottom_left=this_Jindu.jindu_bottom.offset().left
					var click_left=event.pageX
					var jindu_ed=click_left-bottom_left
					if(jindu_ed>this_Jindu.jindu_bottom.width()){
						jindu_ed=this_Jindu.jindu_bottom.width()
					}
					if(jindu_ed<0){
						jindu_ed=0
					}
					this_Jindu.jindu_tiao.css("width",jindu_ed)
					this_Jindu.jindu_dian.css("left",jindu_ed)
					window.move_rate=jindu_ed/this_Jindu.jindu_bottom.width()
					if(mode=="voice"){		//声音进度条
						callback(move_rate)
					}
					$(document).mouseup(function(){
						$(document).off("mousemove")
						if(this_Jindu.move==1&&mode=="jindu"){
							callback(move_rate)
						}
						this_Jindu.move=0
					})
				})
			})
		},
			jindu_tiaoupdate:function(all_time,now_time){
				var all_width=$(".jindu_bottom").width()
				var auto_rate=now_time/all_time*100+"%"
				if(this.move==0){
					$(".jindu_dian").css("left",auto_rate)
					$(".jindu_tiao").css("width",auto_rate)
				}
				else{
					return
				}
				if(all_time==now_time){
					$(".music_next").trigger("click")
				}
			}
	}
	Jindu.prototype.init.prototype=Jindu.prototype
	window.Jindu=Jindu
})(window);